package com.xxxy.controller;

import com.xxxy.commonResult.CommonResult;
import com.xxxy.log.Log;
import com.xxxy.model.AdministrativeClass;
import com.xxxy.model.Student;
import com.xxxy.service.AdministrativeClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author sjh
 * @date 2022/2/3 20:14
 */
@RestController
@Api(tags = "行政班级管理")
@RequestMapping("/administrativeClass")
public class AdministrativeClassController {

    @Autowired
    AdministrativeClassService administrativeClassService;

    @Log(module = "行政班级管理", description = "增加行政班级")
    @GetMapping(value = "/add")
    @ApiOperation(value = "增加行政班级")
    public CommonResult<Boolean> addAdministrativeClass(@ApiParam("行政班级信息") @RequestBody AdministrativeClass administrativeClass) {
        boolean flag = administrativeClassService.save(administrativeClass);
        if (flag) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    @Log(module = "行政班级管理", description = "根据学院查询所属行政班级")
    @GetMapping(value = "/faculty")
    @ApiOperation(value = "根据学院查询所属行政班级")
    public CommonResult<List<AdministrativeClass>> list(@ApiParam("学院id") @RequestParam Integer facultyId) {
        return CommonResult.success(administrativeClassService.getAdministrativeClassByFacultyId(facultyId));
    }

}
